package cn.liweixi.basic.utils;

import lombok.Data;

@Data
public class Result {
    // 返给前端的信息
    private String msg;

    // 返给前端的 true / false
    private Boolean success;

    public static Result me(){
        return new Result();
    }

    public Result success(String msg){
        return me().setMsg(msg).setSuccess(true);
    }

    public Result fail(String msg){
        return me().setMsg(msg).setSuccess(false);
    }

    public Result success(){
        return me().setMsg("操作成功！").setSuccess(true);
    }

    public Result fail(){
        return me().setMsg("操作失败！").setSuccess(false);
    }

    public Result setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Result setSuccess(Boolean success) {
        this.success = success;
        return this;
    }
}
